import Mock from 'mockjs'

// 许可证申报
const count = 100

function getPageList(){
	const List = []
	for (let i = 0; i < count; i++) {
		List.push(Mock.mock({
			id: '@increment', // 记录id
			reportingTime: +Mock.Random.date('T'), // 申报时间
			registrant: '@first', // 登记人
			leadingCadre: '@first', // 企业负责人
			'status|1': [1, 2], // 记录状态 1 可编辑，2不可编辑
		}))
	}
	return List
}

export default [
	// 许可证申报页面
	// {
	// 	url: '/source/getDelarationList',
	// 	type: 'get',
	// 	response: config => {
	// 		const {
	// 			page = 1, limit = 10, sort
	// 		} = config.query

	// 		const pageList = List.filter((item, index) => index < limit * page && index >= limit * (page - 1))

	// 		return {
	// 			code: 200,
	// 			data: {
	// 				total: List.length,
	// 				delarationList: pageList
	// 			}
	// 		}
	// 	}
	// },

	// // 许可证申报页面
	// {
	// 	url: '/source/reportType',
	// 	type: 'get',
	// 	response: config => {
	// 		// 根据企业id判断当前企业能添加什么样的表单
	// 		const {
	// 			id
	// 		} = config.query
	// 		return {
	// 			code: 200,
	// 			data: {
	// 				deviceDate: [{
	// 						time: "2020-02-07",
	// 						status: "1"
	// 					},
	// 					{
	// 						time: "2020-02-08",
	// 						status: "1"
	// 					},
	// 					{
	// 						time: "2020-02-09",
	// 						status: "1"
	// 					}
	// 				],
	// 				sourceDate: [{
	// 						time: "2020-02-07",
	// 						status: "1"
	// 					},
	// 					{
	// 						time: "2020-02-08",
	// 						status: "0"
	// 					},
	// 					{
	// 						time: "2020-02-09",
	// 						status: "1"
	// 					}
	// 				],
	// 			}
	// 		}
	// 	}
	// },

	// // 查看报告的详情
	// {
	// 	url: '/source/reportDetial',
	// 	type: 'get',
	// 	response: config => {
	// 		// 根据申报id查询详情
	// 		const {
	// 			id
	// 		} = config.query
	// 		return {
	// 			code: 200,
	// 			"data|1": {
	// 				deviceData: {
	// 					"useDeviceNum|1-10": 1,
	// 					declareTime: +Mock.Random.date('T'),
	// 					registrant: '@first',
	// 					chargePerson: '@first',
	// 				},
	// 				sourceData: {
	// 					"stockSourceNum|1-10": 2,
	// 					"useSourceNum|1-10": 1,
	// 					declareTime: +Mock.Random.date('T'),
	// 					registrant: '@first',
	// 					chargePerson: '@first',
	// 				},
	// 			}
	// 		}
	// 	}
	// },

	// 企业详情
	{
		url: '/source/entDetial',
		type: 'get',
		response: config => {
			// 企业id
			const {
				id
			} = config.query
			return {
				code: 200,
				data: {
					// 企业的相关信息
					entData: {
						name: '@first',
						entid: '@increment',
						registrant: '@first',
						chargePerson: '@first',
						"sourceNum|1-10": 1
					},
				}
			}
		}
	},
	/**************************************企业端******************************************** */
	// 表格数据
	{
		url: '/DeclareRadRayDeviceLst.asmx/getEnterpriseDeclareLst',
		type: 'post',
		response: config => {
			const {
				page = 1, limit = 10, sort
			} = config.query
			const ls = getPageList()
			const pageList = ls.filter((item, index) => index < limit * page && index >= limit * (page - 1))
			return {
				code: 200,
				data: {
					total: ls.length,
					delarationList: pageList
				}
			}
		}
	},
	// 申报日期
	{
		url: '/DeclareRadRayDeviceLst.asmx/getDeclareDate',
		type: 'post',
		response: config => {
			// 企业id
			const {
				id
			} = config.query
			return {
				code: 200,
				data: {
					deviceDate: [ // 射线装置的日期
						{
							time: "2020-02-07",
							status: "1" // 1表示可以选，0表示已经交过了
						},
						{
							time: "2020-02-08",
							status: "1"
						},
						{
							time: "2020-02-09",
							status: "1"
						}
					],
					sourceDate: [ // 源的日期
						{
							time: "2020-02-07",
							status: "1"
						},
						{
							time: "2020-02-08",
							status: "0"
						},
						{
							time: "2020-02-09",
							status: "1"
						}
					]
				}
			}
		}
	},
	// 申报详情
	{
		url: '/DeclareRadRayDeviceLst.asmx/getReport',
		type: 'post',
		response: config => {
			// 企业id
			const {
				id, type
			} = config.query
			return {
				code: 200,
				data: {
					deviceData: {
						"useDeviceNum|1-10": 1,
						declareTime: +Mock.Random.date('T'),
						registrant: '@first',
						chargePerson: '@first',
					},
					sourceData: {
						"stockSourceNum|1-10": 2,
						"useSourceNum|1-10": 1,
						declareTime: +Mock.Random.date('T'),
						registrant: '@first',
						chargePerson: '@first',
					},
				}
			}
		}
	},
	// 申报/编辑接口
	{
		url: '/DeclareRadRayDeviceLst.asmx/InsertDeclare',
		type: 'post',
		response: config => {
			// const {
			// 	id, type
			// } = config.query
			return {
				code: 200,
				msg: '申报/编辑成功',
				data: {

				}
			}
		}
	},
	/*****************************职能端***************************************** */
	// 表格数据
	{
		url: '/DeclareRadRayDeviceLst.asmx/getDelarationRateList',
		type: 'post',
		response: config => {
			const {
				page = 1, limit = 10, sort
			} = config.query
			let ListZ = []
			for (let i = 0; i < count; i++) {
				ListZ.push(Mock.mock({
					id: '@guid',// 数据id
					enterprise: 'xxxx有限公司', // 企业
					sourceNumber: '6',// 放射源备案源数
					sourceDeclareNumber: '6', // 放射源申报次数
					sourceDeclareRate: '15%',// sourceDeclareRate
					rayDeclareNumber: '6',// 射线装置申报次数
					rayDeclareRate: '15%'// 射线装置申报率
				}))
			}

			const pageList = ListZ.filter((item, index) => index < limit * page && index >= limit * (page - 1))
			return {
				code: 200,
				data: {
					total: ListZ.length,
					delarationRateList: pageList
				}
			}
		}
	},
	// 表格详情数据
	{
		url: '/DeclareRadRayDeviceLst.asmx/getDelarationRateDetailList',
		type: 'post',
		response: config => {
			const {
				sort
			} = config.query
			let ListZ = []
			for (let i = 0; i < 31; i++) {
				ListZ.push(Mock.mock({
					id: '@guid',// 数据id
					rayUseNumber: '4', // 射线装置在用台数
					sourceUseNumber: '2',// 放射源在用源数
					sourceStockNumber: '4',// 放射源在库源数
					sourceRealNumber: '5',// 放射源实有源数
					sourceNumber: '6',// 放射源备案源数
					declareTime: '2019-01-02'// 申报时间
				}))
			}
			const pageList = ListZ
			return {
				code: 200,
				data: {
					total: ListZ.length,
					delarationRateDetailList: pageList
				}
			}
		}
	},
	{
		url: '/DeclareRadRayDeviceLst.asmx/getDelarationRateDetailList',
		type: 'post',
		response: config => {
			// 企业id
			const {
				id, type
			} = config.query
			return {
				code: 200,
				data: {
					deviceData: {
						"useDeviceNum|1-10": 1,
						declareTime: +Mock.Random.date('T'),
						registrant: '@first',
						chargePerson: '@first',
					},
					sourceData: {
						"stockSourceNum|1-10": 2,
						"useSourceNum|1-10": 1,
						declareTime: +Mock.Random.date('T'),
						registrant: '@first',
						chargePerson: '@first',
					},
				}
			}
		}
	},
]
